const express = require('express');
const handle = require('../router_handle/info_handle');
const app = express.Router();
const multer = require('multer');
const path = require('path');
const storage = multer.diskStorage({
	destination: function (req, file, cb) {
		cb(null, path.join(__dirname, '../uploads/avator'));
	},
	filename: function (req, file, cb) {
		cb(null, 'avator' + new Date().valueOf() + path.extname(file.originalname));
	}
})
const upload = multer({
	storage
});

// 查看用户列表(get)
// /info/getUserList
app.get('/getUserList', handle.getUserList);
// 查看管理员列表(get)
// /info/getAdminList
app.get('/getAdminList', handle.getAdminList);
// 查看用户详细信息(get) 通过id获取user
// /info/getUserInfo
// id
app.get('/getUserInfo', handle.getUserInfo);
// 修改用户详细信息(post)(可包括密码也可不包括)
// /info/editUserInfo
// id password(4-12) nickname(1-10) sex  introduction avator 
app.post('/editUserInfo', upload.single('avator'), handle.editUserInfo);
// 删除用户(get)
// /info/deleteUser
// id
app.get('/deleteUser', handle.deleteUser);
// 删除管理员(get)
// /info/deleteAdmin
// id
app.get('/deleteAdmin', handle.deleteAdmin);


module.exports = app